package mycode;

import org.netbeans.jemmy.*;
import org.netbeans.jemmy.operators.*;

public class FindComponentsSample implements Scenario {
    @Override
	public int runIt(Object param) {
	try {
	    new ClassReference("org.netbeans.jemmy.explorer.GUIBrowser").startApplication();
	    JFrameOperator mainFrame = new JFrameOperator("GUI Browser");

            new JButtonOperator(mainFrame, "Reload in").push();

	    //find JTree
	    //we can find any:
	    JTreeOperator tree = new JTreeOperator(mainFrame);

	    //or by selected node:
	    tree.selectPath(tree.findPath("GUI Browser", "|"));
	    new JTreeOperator(mainFrame, "GUI Browser");
	    
	    //There's only one menubar:
	    new JMenuBarOperator(mainFrame);

	    //and couple of text components:
	    new JTextComponentOperator(mainFrame, "0");
	    new JTextComponentOperator(mainFrame, "toString");

	    //but one of them is a test field:
	    new JTextFieldOperator(mainFrame);

	    //and another one is a text area:
	    new JTextAreaOperator(mainFrame);

	    //it's good idea to search buttons by text:
	    new AbstractButtonOperator(mainFrame, "Dump");

	    //but not necessarily
	    new JButtonOperator(mainFrame);
	    //Thread.sleep(100000);
	} catch(Exception e) {
	    e.printStackTrace();
	    return(1);
	}
	return(0);
    }
    public static void main(String[] argv) {
    	String[] params = {"mycode.FindComponentsSample"};
    	org.netbeans.jemmy.Test.main(params);
    }
}
